home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Mesa-2.2 / src-tk / tkbeos.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-03  |  15.2 KB  |  781 lines

  1. /*
  2.  * (c) Copyright 1993, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  36.  */
  37.  
  38. // Mesa Tweaking by: Mark E. Peterson (markp@ic.mankato.mn.us)
  39.  
  40. #include <KernelKit.h>
  41. #include <AppKit.h>
  42. #include <InterfaceKit.h>
  43. #include <stdio.h>
  44. #include <stdlib.h>
  45. #include <string.h>
  46. #include "GL/osmesa.h"
  47. #include "gltk.h"
  48.  
  49. static struct _WINDOWINFO {
  50.     int x, y;
  51.     int width, height;
  52.     GLenum type;
  53.     GLenum dmPolicy;
  54.     int ipfd;
  55.     bool bDefPos;
  56.     char *title;
  57. } windInfo = {
  58.     50, 30, 320, 200, (GLenum)(TK_RGB | TK_SINGLE), (GLenum)0, 0, TRUE, "TKView"
  59. };
  60.  
  61. static void (*ExposeFunc)(int, int)              = NULL;
  62. static void (*ReshapeFunc)(GLsizei, GLsizei)     = NULL;
  63. static void (*DisplayFunc)(void)                 = NULL;
  64. static GLenum (*KeyDownFunc)(int, GLenum)        = NULL;
  65. static GLenum (*MouseDownFunc)(int, int, GLenum) = NULL;
  66. static GLenum (*MouseUpFunc)(int, int, GLenum)   = NULL;
  67. static GLenum (*MouseMoveFunc)(int, int, GLenum) = NULL;
  68. static void (*IdleFunc)(void)                    = NULL;
  69.  
  70. float tkRGBMap[8][3] = {
  71.     {
  72.     0, 0, 0
  73.     },
  74.     {
  75.     1, 0, 0
  76.     },
  77.     {
  78.     0, 1, 0
  79.     },
  80.     {
  81.     1, 1, 0
  82.     },
  83.     {
  84.     0, 0, 1
  85.     },
  86.     {
  87.     1, 0, 1
  88.     },
  89.     {
  90.     0, 1, 1
  91.     },
  92.     {
  93.     1, 1, 1
  94.     }
  95. };
  96.  
  97. static uchar idxlist[256];
  98. static uchar *tmpout;
  99. static uchar *bits;
  100.  
  101. /***************************************************************
  102.  *                                                             *
  103.  *  BeOS stuff                                                 *
  104.  *                                                             *
  105.  ***************************************************************/
  106.  
  107. const     ulong             APP_SIGNATURE = '????';
  108. const     ulong            MSG_REDRAW = 1;
  109.  
  110. class                     MesaWindow;
  111. class                     MesaView;
  112. class                    MesaApp;
  113.  
  114. // Lets make our life easy and make them global:
  115.  
  116. OSMesaContext             ctx;    
  117. BBitmap                 *the_bitmap;
  118. MesaView                *the_view;    
  119. MesaWindow                 *the_window;
  120. MesaApp                 *the_app;
  121.  
  122. class MesaView : public BView
  123. {
  124.     BRect Bound;
  125.  
  126.     public:
  127.     
  128.     MesaView(BRect frame):BView(frame,"Mesa View",B_FOLLOW_NONE,B_WILL_DRAW)
  129.     {
  130.         Bound=Bounds();
  131.     };
  132.     
  133.     void MouseDown(BPoint pos)
  134.     {
  135.         ulong buttons;
  136.         ulong mask;
  137.  
  138.         Window()->Lock();
  139.         GetMouse(&pos,&buttons);
  140.         Window()->Unlock();
  141.  
  142.         if(MouseDownFunc)
  143.         {
  144.  
  145.             mask = 0;
  146.             if (buttons & B_PRIMARY_MOUSE_BUTTON) {
  147.                 mask |= TK_LEFTBUTTON;
  148.             }
  149.             if (buttons & B_SECONDARY_MOUSE_BUTTON) {
  150.                 mask |= TK_MIDDLEBUTTON;
  151.             }
  152.             if (buttons & B_TERTIARY_MOUSE_BUTTON) {
  153.                 mask |= TK_RIGHTBUTTON;
  154.             }
  155.  
  156.             (*MouseDownFunc)(pos.x,pos.y,(GLenum)mask);
  157.             if( DisplayFunc)
  158.             {
  159.                 (*DisplayFunc)();
  160.                 Window()->Lock();
  161.                     Draw(Bound);
  162.                     Window()->Unlock();
  163.             }
  164.         }
  165.  
  166.         while(buttons)
  167.         {
  168.             Window()->Lock();
  169.             GetMouse(&pos,&buttons);
  170.             Window()->Unlock();
  171.  
  172.             if(MouseMoveFunc)
  173.             {
  174.             
  175.                 mask = 0;
  176.                 if (buttons & B_PRIMARY_MOUSE_BUTTON) {
  177.                     mask |= TK_LEFTBUTTON;
  178.                 }
  179.                 if (buttons & B_SECONDARY_MOUSE_BUTTON) {
  180.                     mask |= TK_MIDDLEBUTTON;
  181.                 }
  182.                 if (buttons & B_TERTIARY_MOUSE_BUTTON) {
  183.                     mask |= TK_RIGHTBUTTON;
  184.                 }
  185.                 (*MouseUpFunc)(pos.x,pos.y,(GLenum)mask);
  186.                 if( DisplayFunc)
  187.                 {
  188.                     (*DisplayFunc)();
  189.                     Window()->Lock();
  190.                         Draw(Bound);
  191.                         Window()->Unlock();
  192.                 }
  193.             }
  194.         }
  195.  
  196.         if(MouseUpFunc)
  197.         {
  198.             mask = 0;
  199.             if (buttons & B_PRIMARY_MOUSE_BUTTON) {
  200.                 mask |= TK_LEFTBUTTON;
  201.             }
  202.             if (buttons & B_SECONDARY_MOUSE_BUTTON) {
  203.                 mask |= TK_MIDDLEBUTTON;
  204.             }
  205.             if (buttons & B_TERTIARY_MOUSE_BUTTON) {
  206.                 mask |= TK_RIGHTBUTTON;
  207.             }
  208.  
  209.             (*MouseUpFunc)(pos.x,pos.y,(GLenum)mask);
  210.             if( DisplayFunc)
  211.             {
  212.                 (*DisplayFunc)();
  213.                 Window()->Lock();
  214.                     Draw(Bound);
  215.                     Window()->Unlock();
  216.             }
  217.         }
  218.     };
  219.     
  220.     void KeyDown(ulong aKey)
  221.     {
  222.         int key;
  223.         GLenum mask=(GLenum)0;
  224.         
  225.         switch(aKey)
  226.         {
  227.             case B_SPACE:
  228.                     key = TK_SPACE;
  229.                     break;
  230.             case B_ESCAPE:
  231.                     key = TK_ESCAPE;
  232.                     break;
  233.             case '1':
  234.                     key = TK_1;
  235.                     break;
  236.             case '2':
  237.                     key = TK_2;
  238.                     break;
  239.             case '3':
  240.                     key = TK_3;
  241.                     break;
  242.             case '4':
  243.                     key = TK_4;
  244.                     break;
  245.             case '5':
  246.                     key = TK_5;
  247.                     break;
  248.             case '6':
  249.                     key = TK_6;
  250.                     break;
  251.             case '7':
  252.                     key = TK_7;
  253.                     break;
  254.             case '8':
  255.                     key = TK_8;
  256.                     break;
  257.             case '9':
  258.                     key = TK_9;
  259.                     break;
  260.             case '0':
  261.                     key = TK_0;
  262.                     break;
  263.             case 'a':
  264.                     key = TK_a;
  265.                     break;
  266.             case 'b':
  267.                     key = TK_b;
  268.                     break;
  269.             case 'c':
  270.                     key = TK_c;
  271.                     break;
  272.             case 'd':
  273.                     key = TK_d;
  274.                     break;
  275.             case 'e':
  276.                     key = TK_e;
  277.                     break;
  278.             case 'f':
  279.                     key = TK_f;
  280.                     break;
  281.             case 'g':
  282.                     key = TK_g;
  283.                     break;
  284.             case 'h':
  285.                     key = TK_h;
  286.                     break;
  287.             case 'i':
  288.                     key = TK_i;
  289.                     break;
  290.             case 'j':
  291.                     key = TK_j;
  292.                     break;
  293.             case 'k':
  294.                     key = TK_k;
  295.                     break;
  296.             case 'l':
  297.                     key = TK_l;
  298.                     break;
  299.             case 'm':
  300.                     key = TK_m;
  301.                     break;
  302.             case 'n':
  303.                     key = TK_n;
  304.                     break;
  305.             case 'o':
  306.                     key = TK_o;
  307.                     break;
  308.             case 'p':
  309.                     key = TK_p;
  310.                     break;
  311.             case 'q':
  312.                     key = TK_q;
  313.                     break;
  314.             case 'r':
  315.                     key = TK_r;
  316.                     break;
  317.             case 's':
  318.                     key = TK_s;
  319.                     break;
  320.             case 't':
  321.                     key = TK_t;
  322.                     break;
  323.             case 'u':
  324.                     key = TK_u;
  325.                     break;
  326.             case 'v':
  327.                     key = TK_v;
  328.                     break;
  329.             case 'w':
  330.                     key = TK_w;
  331.                     break;
  332.             case 'x':
  333.                     key = TK_x;
  334.                     break;
  335.             case 'y':
  336.                     key = TK_y;
  337.                     break;
  338.             case 'z':
  339.                     key = TK_z;
  340.                     break;
  341.             case 'A':
  342.                     key = TK_A;
  343.                     break;
  344.             case 'B':
  345.                     key = TK_B;
  346.                     break;
  347.             case 'C':
  348.                     key = TK_C;
  349.                     break;
  350.             case 'D':
  351.                     key = TK_D;
  352.                     break;
  353.             case 'E':
  354.                     key = TK_E;
  355.                     break;
  356.             case 'F':
  357.                     key = TK_F;
  358.                     break;
  359.             case 'G':
  360.                     key = TK_G;
  361.                     break;
  362.             case 'H':
  363.                     key = TK_H;
  364.                     break;
  365.             case 'I':
  366.                     key = TK_I;
  367.                     break;
  368.             case 'J':
  369.                     key = TK_J;
  370.                     break;
  371.             case 'K':
  372.                     key = TK_K;
  373.                     break;
  374.             case 'L':
  375.                     key = TK_L;
  376.                     break;
  377.             case 'M':
  378.                     key = TK_M;
  379.                     break;
  380.             case 'N':
  381.                     key = TK_N;
  382.                     break;
  383.             case 'O':
  384.                     key = TK_O;
  385.                     break;
  386.             case 'P':
  387.                     key = TK_P;
  388.                     break;
  389.             case 'Q':
  390.                     key = TK_Q;
  391.                     break;
  392.             case 'R':
  393.                     key = TK_R;
  394.                     break;
  395.             case 'S':
  396.                     key = TK_S;
  397.                     break;
  398.             case 'T':
  399.                     key = TK_T;
  400.                     break;
  401.             case 'U':
  402.                     key = TK_U;
  403.                     break;
  404.             case 'V':
  405.                     key = TK_V;
  406.                     break;
  407.             case 'W':
  408.                     key = TK_W;
  409.                     break;
  410.             case 'X':
  411.                     key = TK_X;
  412.                     break;
  413.             case 'Y':
  414.                     key = TK_Y;
  415.                     break;
  416.             case 'Z':
  417.                     key = TK_Z;
  418.                     break;
  419.             case B_LEFT_ARROW:
  420.                     key = TK_LEFT;
  421.                     break;
  422.             case B_RIGHT_ARROW:
  423.                     key = TK_RIGHT;
  424.                     break;
  425.             case B_UP_ARROW:
  426.                     key = TK_UP;
  427.                     break;
  428.             case B_DOWN_ARROW:
  429.                     key = TK_DOWN;
  430.                     break;
  431.             default:
  432.                     return;
  433.         }
  434.         if(KeyDownFunc)
  435.         {
  436.             (*KeyDownFunc)(key,mask);
  437.         }
  438.         if( DisplayFunc)
  439.         {
  440.             (*DisplayFunc)();
  441.             Window()->Lock();
  442.                 Draw(Bound);
  443.                 Window()->Unlock();
  444.         }
  445.     };
  446.     
  447.     void Draw(BRect frame)
  448.     {
  449.         DrawBitmap(the_bitmap,BPoint(0,0));
  450.     };                    
  451. };
  452.  
  453. class MesaWindow : public BWindow 
  454. {
  455.     public:
  456.     
  457.     MesaWindow(int width, int height):BWindow(BRect(0,0,width-1,height-1),"MesaView",B_TITLED_WINDOW,B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
  458.     {
  459.         MoveTo(windInfo.x,windInfo.y);
  460.         Lock();
  461.         AddChild(the_view = new MesaView(BRect(0, 0, width, height)));
  462.         the_view->MakeFocus();
  463.         Unlock();
  464.     };
  465.     
  466.     void MessageReceived(BMessage *msg)
  467.     {
  468.         switch(msg->what)
  469.         {    
  470.             case    MSG_REDRAW:
  471. /*                    if(tmpout)
  472.                     {
  473.                         int l=(the_bitmap->BytesPerRow()*windInfo.height);
  474.                         for(int i=0;i<l;i++)
  475.                         {
  476.                             bits[i]=idxlist[tmpout[i]];
  477.                         }
  478.                     }*/
  479.                     Lock();
  480.                     the_view->DrawBitmap(the_bitmap,BPoint(0,0));
  481.                     Unlock();
  482.                        if (IdleFunc)
  483.                     {
  484.                         (*IdleFunc)();
  485.                         PostMessage(MSG_REDRAW);
  486.                     }
  487.                     break;
  488.             default:
  489.                     BWindow::MessageReceived(msg);
  490.                     break;
  491.         }
  492.     };
  493.     
  494.     bool QuitRequested(void)
  495.     {
  496.         be_app->PostMessage(B_QUIT_REQUESTED);
  497.         return TRUE;
  498.     };
  499. };
  500.  
  501. class MesaApp : public BApplication 
  502. {
  503.     public:
  504.     
  505.     MesaApp():BApplication(APP_SIGNATURE)
  506.     {
  507.         the_window = NULL;
  508.         the_bitmap = NULL;
  509.     };
  510.             
  511.     void ReadyToRun(void)
  512.     {
  513.         the_window = new MesaWindow(windInfo.width,windInfo.height);
  514.         the_window->Show();
  515.         if(ExposeFunc)
  516.         {
  517.             (*ExposeFunc)(windInfo.width,windInfo.height);
  518.         }        
  519.         if(ReshapeFunc)
  520.         {
  521.             (*ReshapeFunc)(windInfo.width,windInfo.height);
  522.         }
  523.         if( DisplayFunc)
  524.         {
  525.             (*DisplayFunc)();
  526.         }
  527.         the_window->PostMessage(MSG_REDRAW);
  528.     };
  529.  
  530.     bool QuitRequested(void)
  531.     {
  532.         if (BApplication::QuitRequested()) 
  533.         {
  534.             if (the_bitmap)    delete the_bitmap;
  535.             if (ctx) OSMesaDestroyContext( ctx );
  536.             return TRUE;
  537.         }
  538.         return FALSE;
  539.     };
  540.             
  541.     void AboutRequested(void)
  542.     {
  543.         char str[256];
  544.         sprintf(str, "MesaDemos, ported by Tinic Urou\n<5uro@informatik.uni-hamburg.de>\nFreely distributable.");
  545.         BAlert *the_alert = new BAlert("", str, "OK");
  546.         the_alert->Go();
  547.     };
  548. };
  549.  
  550.  
  551. /***************************************************************
  552.  *                                                             *
  553.  *  Exported Functions go here                                 *
  554.  *                                                             *
  555.  ***************************************************************/
  556.  
  557. void tkErrorPopups(GLboolean bEnable)
  558. {
  559. }
  560.  
  561. void tkCloseWindow(void)
  562. {
  563. }
  564.  
  565. void tkExec(void)
  566. {
  567.     the_app->Run();
  568.     delete the_app;
  569.     exit(0);
  570. }
  571.  
  572. void tkExposeFunc(void (*Func)(int, int))
  573. {
  574.     ExposeFunc = Func;
  575. }
  576.  
  577. void tkReshapeFunc(void (*Func)(GLsizei, GLsizei))
  578. {
  579.     ReshapeFunc = Func;
  580. }
  581.  
  582. void tkDisplayFunc(void (*Func)(void))
  583. {
  584.     DisplayFunc = Func;
  585. }
  586.  
  587. void tkKeyDownFunc(GLenum (*Func)(int, GLenum))
  588. {
  589.     KeyDownFunc = Func;
  590. }
  591.  
  592. void tkMouseDownFunc(GLenum (*Func)(int, int, GLenum))
  593. {
  594.     MouseDownFunc = Func;
  595. }
  596.  
  597. void tkMouseUpFunc(GLenum (*Func)(int, int, GLenum))
  598. {
  599.     MouseUpFunc = Func;
  600. }
  601.  
  602. void tkMouseMoveFunc(GLenum (*Func)(int, int, GLenum))
  603. {
  604.     MouseMoveFunc = Func;
  605. }
  606.  
  607. void tkIdleFunc(void (*Func)(void))
  608. {
  609.     IdleFunc = Func;
  610. }
  611.  
  612. void tkInitPosition(int x, int y, int width, int height)
  613. {
  614.    windInfo.bDefPos = FALSE;
  615.    windInfo.x = x ;
  616.    windInfo.y = y ;
  617.    windInfo.width = width;
  618.    windInfo.height = height;
  619. }
  620.  
  621. void tkInitDisplayMode(GLenum type)
  622. {
  623.     windInfo.type = type;
  624. }
  625.  
  626. void tkInitDisplayModePolicy(GLenum type)
  627. {
  628.     windInfo.dmPolicy = type;
  629. }
  630.  
  631. GLenum tkInitDisplayModeID(GLint ipfd)
  632. {
  633.     windInfo.ipfd = ipfd;
  634.     return GL_TRUE;
  635. }
  636.  
  637. GLenum tkInitWindowAW(char *title, bool bUnicode)
  638. {
  639.      windInfo.title=title;
  640.     int realw;
  641.     color_space type;
  642.     
  643.     
  644.     // What a hack!
  645.     the_app = new MesaApp();
  646.  
  647.     switch(windInfo.type)
  648.     {
  649.         case    TK_RGB:
  650.                 type=B_RGB_32_BIT;
  651.                 break;
  652.         case    TK_INDEX:
  653.                 type=B_COLOR_8_BIT;
  654.                 break;
  655.     }
  656.  
  657.     // other mode does not work now
  658.     type=B_RGB_32_BIT;
  659.     windInfo.type=(GLenum)TK_RGB;
  660.  
  661.     the_bitmap = new BBitmap(BRect(0, 0, windInfo.width,windInfo.height),type);
  662.     bits = (uchar *)the_bitmap->Bits();
  663.  
  664.     switch(type)
  665.     {
  666.         case    B_RGB_32_BIT:
  667.                 realw=the_bitmap->BytesPerRow()/sizeof(ulong);
  668.                 ctx = OSMesaCreateContext( GL_RGBA, NULL );
  669.                 tmpout=0;
  670.                 memset(bits,0,the_bitmap->BytesPerRow()*windInfo.height);
  671.                 OSMesaMakeCurrent( ctx, bits, GL_UNSIGNED_BYTE,realw,windInfo.height);
  672.                 break;
  673.         case    B_COLOR_8_BIT:
  674.                 realw=the_bitmap->BytesPerRow();
  675.                 ctx = OSMesaCreateContext( GL_COLOR_INDEX, NULL );
  676.                 tmpout=new uchar[the_bitmap->BytesPerRow()*windInfo.height];
  677.                 memset(tmpout,0,the_bitmap->BytesPerRow()*windInfo.height);
  678.                 OSMesaMakeCurrent( ctx, tmpout, GL_UNSIGNED_BYTE,realw,windInfo.height);
  679.                 break;
  680.     }
  681.     OSMesaPixelStore( OSMESA_Y_UP, 0 );
  682.  
  683.     return GL_TRUE;
  684. }
  685.  
  686. GLenum tkInitWindow(char *title)
  687. {
  688.     return tkInitWindowAW(title, FALSE);
  689. }
  690.  
  691.  
  692. /******************************************************************************/
  693.  
  694. /*
  695.  * You cannot just call DestroyWindow() here.  The programs do not expect
  696.  * tkQuit() to return;  DestroyWindow() just sends a WM_DESTROY message
  697.  */
  698.  
  699. void tkQuit(void)
  700. {
  701.     be_app->PostMessage(B_QUIT_REQUESTED);
  702. }
  703.  
  704. /******************************************************************************/
  705.  
  706. void set_onecolor(int k, uchar r, uchar g, uchar b)
  707. {
  708.     idxlist[(k&0xFF)]=index_for_color(r,g,b);
  709. }
  710.  
  711. void tkSetOneColor(int index, float r, float g, float b)
  712. {
  713.     unsigned char R=r*255.0,G=g*255.0,B=b*255.0;
  714.     set_onecolor(index,R,G,B);
  715. }
  716.  
  717. void tkSetFogRamp(int density, int startIndex)
  718. {
  719.     int n, i, j, k, intensity, fogValues, colorValues;
  720.  
  721.     fogValues = 1 << density ;
  722.     colorValues = 1 << startIndex ;
  723.     for( i = 0 ; i < colorValues; i++ ) {
  724.         for( j = 0 ; j < fogValues; j++ ) {
  725.             k = i * fogValues + j;
  726.  
  727.             intensity = i * fogValues + j * colorValues;
  728.  
  729.             if( intensity > 0xff )
  730.                 intensity = 0xff;
  731.  
  732.             set_onecolor(k,intensity,intensity,intensity);
  733.         }
  734.     }
  735. }
  736.  
  737. void tkSetGreyRamp(void)
  738. {
  739.     int Count,i;
  740.     float intensity;
  741.     Count = tkGetColorMapSize();
  742.     for( i = 0 ; i < Count ; i++ )
  743.     {
  744.         intensity = (float)(((double)i / (double)(Count-1)) * (double)255.0 + (double)0.5);
  745.         set_onecolor(i,intensity,intensity,intensity);
  746.     }
  747. }
  748.  
  749. void tkSetRGBMap( int Size, float *Values )
  750. {
  751.     for (int i=0; i<Size; i++) tkSetOneColor(i,Values[i*3],Values[i*3+1],Values[i*3+2]);
  752. }
  753.  
  754. void tkSwapBuffers(void)
  755. {
  756. }
  757.  
  758. GLint tkGetColorMapSize(void)
  759. {
  760.     return 256;
  761. }
  762.  
  763. void tkGetMouseLoc(int *x, int *y)
  764. {
  765. }
  766.  
  767. GLenum tkGetDisplayModePolicy(void)
  768. {
  769.     return windInfo.dmPolicy;
  770. }
  771.  
  772. GLint tkGetDisplayModeID(void)
  773. {
  774.     return windInfo.ipfd;
  775. }
  776.  
  777. GLenum tkGetDisplayMode(void)
  778. {
  779.     return windInfo.type;
  780. }
  781.